/**
 * <p>Copyright: Copyright (c) 2014</p>
 * <p>Company: ---Technology Co. Ltd</p>
 * <p>2014-4-29</p>
 * @author Jan.Zhang
 */
package com.xianl.busiplat.dao;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.type.TypeException;
import com.xianl.busiplat.dwz.Page;


/** 
 * desc: Base Dao Interface , All the common Dao implements could be extend this class
 * <p>author: Jan.Zhang </p>
 * date: 2014-4-29
 */
public interface BaseDao<T> {
	
	/**
	 * desc: get the Sql Session created by Mybatis 
	 * <p>author: Jan.Zhang </p>
	 *  date : 2014-4-29 
	 * @return
	 * @throws TypeException
	 * @throws SQLException
	 * @throws Exception
	 */
	public SqlSession getSqlSession();
	
	/**
	 * desc: insert a model to the database
	 * <p>author: Jan.Zhang </p>
	 *  date : 2014-4-29 
	 * @param t
	 * @throws TypeException
	 * @throws SQLException
	 * @throws Exception
	 */
	public void insert(String statement, T t);
	
	public void insert(T t);
	
	/**
	 * desc:find all results 
	 * <p>author: Jan.Zhang </p>
	 *  date : 2014-4-29 
	 * @param t
	 * @return
	 * @throws TypeException
	 * @throws SQLException
	 * @throws Exception
	 */
	public List<T> findAll(String statement, T t);
	public List<T> findAll(T t);
	
	/**
	 * desc:find all results  at pages
	 * <p>author: Jan.Zhang </p>
	 *  date : 2014-4-29 
	 * @param t
	 * @param pageNo
	 * @param pageSize
	 * @return
	 * @throws TypeException
	 * @throws SQLException
	 * @throws Exception
	 */
	public List<T> findPage(String statement, Page page, Map params);
	public List<T> findPage(Page page, Map params);
	
	/**
	 * desc: find one result
	 * <p>author: Jan.Zhang </p>
	 *  date : 2014-4-29 
	 * @param t
	 * @return
	 * @throws TypeException
	 * @throws SQLException
	 * @throws Exception
	 */
	public T selectOne(String statement, T t);
	public T selectOne(T t);
	
	/**
	 * desc: update a model to the database
	 * <p>author: Jan.Zhang </p>
	 *  date : 2014-4-29 
	 * @param t
	 * @throws TypeException
	 * @throws SQLException
	 * @throws Exception
	 */
	public void update(String statement,T t);
	public void update(T t);
	
	public void delete(String statement, T t);
	public void delete(T t);
	
	public void clearCache();
}
